//判断code
function interceptCode(data) {
    if (!data instanceof Object) {
        return
    }
    switch (data.code) {
        case 666:
            break;
        case 668:
            break;
        case 304:
            break;
        case 405:
            break;
        case 406:
            alert('请先登录')
            window.location.replace('Login.html');
            return false
            break;
        case 500:
            break;
    }
}

//Ajax拦截器
function Interceptor(url, method, data) {
    let Data = '';

    $.ajax({
        url: 'http://119.23.46.241:2121' + url,
        type: method,
        dataType: 'json',
        async: false,
        data: data,
        contentType: 'application/x-www-form-urlencoded',
        cache: false,
        beforeSend: function (XMLHttpRequest) {
            let token = sessionStorage.getItem('Authorization')
            token = token ? token : '';
            XMLHttpRequest.setRequestHeader('Authorization', token)
        },
        success: function (result) {
            Data = result;
            interceptCode(result)
        },

        error: function (result) {
            Data = result;
            interceptCode(result)
        },
    });
    return Data;
}